Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add login page (Backend) #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Add login page (Backend) #16

wants to merge 1 commit into from

Conversation

archeoss
Copy link
Contributor

@archeoss archeoss commented Oct 5, 2023

partly resolves the #2 issue

@archeoss
Copy link
Contributor Author

archeoss commented Oct 5, 2023

@archeoss
Copy link
Contributor Author

Need some time to tidy up everything, but generally everything should be done for this PR

@archeoss archeoss closed this Oct 12, 2023
@archeoss archeoss reopened this Oct 12, 2023
@archeoss archeoss force-pushed the 2-login-page branch 2 times, most recently from 22b2cbb to 3c6aff8 Compare October 13, 2023 14:44
@archeoss archeoss changed the title Add login page Add login page (Backend) Oct 13, 2023
@archeoss archeoss linked an issue Oct 13, 2023 that may be closed by this pull request
backend/src/main.rs Outdated Show resolved Hide resolved
@@ -0,0 +1,349 @@
use super::prelude::*;

pub type HttpClient = ContextWrapper<
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain what's going on with ClientContext here? Why do you declare the Client without context (DropContextService) and then wrap it with context? What is the reason that Client was not declared directly with the context?

Copy link
Contributor Author

@archeoss archeoss Jan 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, we can wrap any context with any context provider (for example, the one that reads\writes context from\to file, and not that just wraps the context and keeps it in-memory). Practically, It could be solved with generic types and some methods, not the whole wrapper, but since that was the part of auto-generated code, I decided to keep it this way
Also we can replace the context on specific calls, not changing the wrapped one, but I fail to see the situation where that's actually useful (and the wrapper part too)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I understand that generics are used for better flexibility. But here a specific type with all substitutions is declared. Why are additional layers needed here? Why can't it be written like this:

pub type HttpClient = ContextWrapper<
    Client<
        hyper::Client<HttpConnector, Body>,
        ClientContext,
        Basic,
    >,
    ClientContext,
>;

@ikopylov ikopylov changed the base branch from 11-configure-cicd to main December 22, 2023 16:36
@@ -5,8 +5,10 @@ Bob Management GUI changelog
## [Unreleased]

#### Added

Copy link
Member

@ikopylov ikopylov Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary empty line

}

#[derive(Clone)]
pub struct BobClient<Client: ApiNoContext<ClientContext> + Send + Sync> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps, it is better to call it BobClusterClient, because inside it contains clients for all nodes

@@ -136,22 +181,38 @@ impl<V, D, S, B> Deref for ContextRouter<V, D, S, B> {
}
}

#[cfg(all(feature = "swagger", debug_assertions))]
pub trait RouterApiExt<S = (), B = Body, E = Infallible> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see no difference between this trait and the one below. Looks like the separation based on cfg is not needed on trait declaration level

}
}

#[cfg(all(feature = "swagger", debug_assertions))]
Copy link
Member

@ikopylov ikopylov Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The separation of implementations occurs at different levels. Here the struct level is used, and above - the function level. It is better to unify places, where cfg is applied. It seems that it is better to make a separation at the function level here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference seems to be the call to check_api, I suggest to cfg only the call and the function itself

}

#[cfg(not(all(feature = "swagger", debug_assertions)))]
Copy link
Member

@ikopylov ikopylov Jan 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Implementations are also look identical

Ok(res)
}

#[async_trait]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like async_trait can be removed here

}
}

#[async_trait]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like async_trait is not needed here

@archeoss archeoss mentioned this pull request Jan 29, 2024
4 tasks
let connector = Connector::builder();

let client_service = match scheme.as_str() {
"http" => HyperClient::Http(hyper::client::Client::builder().build(connector.build())),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about https, can it be added? bob technically supports it


let cluster: HashMap<NodeName, Arc<_>> = nodes
.iter()
.filter_map(|node| HttpClient::from_node(node, &bob_data.hostname, context.clone()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API ports can be different on each node, and they are not known to other nodes. There should be a way to override default ports. In bob-tools it's done with argument api-port, Override default api port for the node. E.g. node1:80,node2:8000. Wildcard char (*) can be used to set port for all nodes.

}
}

/// Probes connection to the Bob's main connected node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment out of sync?


// NOTE: Can (and should) the API interface mutate?..
/// Connection,
main: Arc<Client>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason to have single main node? Why not any other node in cluster?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Login page
3 participants